#ifndef _BOOTSTRAP_H_
#define _BOOTSTRAP_H_

#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif

#include "..\Persistence\persistence\EntityRepository.h"
#include "..\Persistence\persistence\PersistenceException.h"
#include "..\Persistence\persistence\SceneRepository.h"
#include "view\ClientView.h"
#include "net\TCPSocket.h"
#include "AsteroidsMenuListener.h"
#include "AsteroidsServer.h"
#include "AsteroidsClient.h"
#include "concurrent\Thread.h"
#include "Utils.h"
#include "Logger.h"
#include <iostream>
#include <list>

using namespace persistence;
using namespace util;
using namespace std;

namespace model 
{
	class Asteroid;
	class Bonus;
	class Bullet;
	class Scene;
	class Ship;
};

namespace view
{
	class Window;
	class StartWindow;
};

namespace sdl
{
	class SDLSurface;
	class Mixer;
};

class Bootstrap
{
public:
	Bootstrap(void);
	virtual ~Bootstrap(void);

	void start       (void);
	void launchServer(void);
	void launchClient(void);
	void gameFinished(void);
	void quitGame    (void);
	void quit        (void);

	void updateServerStatus(string status);
	void updateClientStatus(string status);
	void setSelectedShip   (string ship) { selectedShip = ship;}
	void startGame         (string sceneFile);
	void updateEntities(map<int, EntityData> asteroidsData, list<ShipData> shipsData, map<int, BulletData> bulletsData,
		map<int, EntityData> bonusData);
	void setOwnShipId(int shipId);
	void setOtherPlayerName(string otherPlayerName);
	string getOtherPlayerName(void);

private:
	void showMenu(void);
	void showGame(void);
	void cleanPendingEntities(void);

	sdl::SDLSurface* mainSurface;
	sdl::Mixer* sound;
	view::StartWindow* window;
	auto_ptr<view::ClientView> clientView;
	map<int, Asteroid*> asteroidsmap;
	list<model::Ship*> ships;
	list<model::Base*> bases;
	map<int, model::Bullet*> bullets;
	map<int, model::Bonus*> bonuses;
	list<model::Entity*> pendingToDelete;
	auto_ptr<AsteroidsServer> server;
	auto_ptr<AsteroidsClient> client;
	string selectedShip;
	string gameSceneFile;
	bool showGameView, gameInitialized;
	int ownShipId;
	string otherPlayerName;
};

#endif
